<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <script src="__PUBLIC__/js/jquery.min.js"></script>
    <script src="__PUBLIC__/home/plugins/layer/layer.js"></script>
    <script src="__PUBLIC__/mui/js/mui.min.js"></script>
    <script src="__PUBLIC__/js/angular.js"></script>
    <script src="__PUBLIC__/common.js"></script>
    <!--标准mui.css-->
    <link rel="stylesheet" href="__PUBLIC__/mui/css/mui.css">
    <!--App自定义的css-->
    <link rel="stylesheet" href="__PUBLIC__/css/app.css">
    <link rel="stylesheet" href="__PUBLIC__/css/index.css">
    <link rel="stylesheet" href="__PUBLIC__/css/new_z.css">
</head>
<body ng-app="myApp">
<!--header-->
<header class="mui-bar mui-bar-nav">
    <h1 class="mui-title"> 水苑共享商城<!--{{ agen.name }}--></h1>
    <a class="m_cart" href="{:U('cart/cart')}">
        <i></i>
    </a>
    <a class="m_search" href="{:U('product/search')}">
        <i></i>
    </a>
</header>
<div style="height: 44px"></div>
<!--banner-->
<div id="slider" class="mui-slider" ng-controller="showCtrl" ng-cloak>
    <div class="mui-slider-group mui-slider-loop">
        <!-- 额外增加的一个节点(循环轮播：第一个节点是最后一张轮播) -->
        <div class="mui-slider-item mui-slider-item-duplicate">
            <a href="{{banner2.url}}">
                <img ng-src="{{last.img}}">
            </a>
        </div>
        <div class="mui-slider-item">
            <a href="{{banner1.url}}">
                <img ng-src="{{banner1.img}}">
            </a>
        </div>
        <div class="mui-slider-item">
            <a href="{{banner2.url}}">
                <img ng-src="{{banner2.img}}">
            </a>
        </div>
        <div class="mui-slider-item" ng-show="banner3.img != null">
            <a href="{{banner3.url}}">
                <img ng-src="{{banner3.img}}">
            </a>
        </div>
        <!-- 额外增加的一个节点(循环轮播：最后一个节点是第一张轮播) -->
        <div class="mui-slider-item mui-slider-item-duplicate">
            <a href="{{banner1.url}}">
                <img ng-src="{{first.img}}">
            </a>
        </div>
    </div>
    <div class="mui-slider-indicator">
        <div class="mui-indicator mui-active" ng-repeat="x in banner"></div>
    </div>
</div>
<!--正文/商品-->
<div class="nav_ss flex" ng-controller="noticeCtrl">
    <div class="pd10">
        <img src="__PUBLIC__/images/home_icon_notice@2x.png" alt="">
    </div>
    <span>|</span>
    <div class="flex1">
        <div class="anner">
            <ul class="marque" style="margin-top: 0px;">
                <li ng-repeat="no in notice" ng-click="gonggao(no.id)">
                    <a href="javascript:void(0)">
                        {{no.title}}
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <a class="more_nt" href="{:U('Index/article')}">
        更多 >
    </a>
</div>
<div class="mui-content goods " style="position: relative;padding-top: 10px;">
    <ul class="good" ng-controller="productCtrl"
        style="padding-left:0;display: flex; flex-flow: wrap;margin-top: 0%;margin-bottom: 1%;background: #FFFFFF; ">
        <li class="mui-table-view-cell mui-media mui-col-xs-6 goods-list" ng-repeat="pro in product"
            style="padding: 0;margin: 0">
            <a href="{:U('Product/index')}?id={{pro.id}}"
               style="margin: 0px 1.5px 3px 1.5px;background: white;padding: 3px">
                <div class="goods-image" ><img ng-src="{{pro.img}}" class="mui-col-xs-12"></div>
                <p class="mui-text-left goods-name" style="color:#4D4D4D;font-size: 15px;">{{pro.name}}</p>
                <p class="mui-text-left goods-price">￥{{pro.price}}</p>
            </a>
        </li>
    </ul>
</div>
<div style="height: 50px"></div>
<div ng-controller="wxCtrl"></div>
<!--footer-->
<include file="./Application/Home/View/pub/foot.html" name="i"/>
</body>
<script>
    mui.init({
        swipeBack: true //启用右滑关闭功能
    });
    var slider = mui("#slider");
    slider.slider({
        interval: 1500
    });
    $(function () {
        $(".mui-tab-item").click(function () {
            window.location.href = $(this).attr("href")
        })
    })
</script>
<script>
    var app = getApp('myApp', []);

    app.controller('wxCtrl', function ($scope, $http) {
        $scope.code = getUrlParam('code');
        //非空，微信登录
        if ($scope.code != null && $scope.code != '') {
            $http({
                method: 'GET',
                url: "/index.php/Home/login/wxLogin?code=" + $scope.code
            }).then(function successCallback(response) {
                //console.log(response.data)
                if (response.data.code == -1) {
                    layer.msg(response.data.msg.msg, {time: 1000})
                    setTimeout(function () {
                        window.location.href = "/index.php/Home/index/login";
                    }, 1000)
                } else if (response.data.code == 0) {
                    layer.msg(response.data.data.msg, {time: 1000})
                }
            }, function errorCallback(response) {
                errorHandle(response);
            });
        }
    });

    // 公告
    app.controller('noticeCtrl', function ($scope, $http) {
        $http({
            method: 'POST',
            url: "/index.php/Home/Index/notice"
        }).then(function successCallback(response) {
            successHandle(response, function (data) {
                //$scope.notice = data;
                $scope.notice = [];
                for (var i in data) {
                    $scope.notice.push(data[i]);
                }
            });
        }, function errorCallback(response) {
            errorHandle(response);
        });

        $scope.gonggao = function (id) {
            window.location.href = "/index.php/Home/Index/articlectn?id=" + id;
        }
    });

    // 轮播图
    app.controller('showCtrl', function ($scope, $http) {
        $http({
            method: 'POST',
            url: "/index.php/Home/Index/show"
        }).then(function successCallback(response) {
            successHandle(response, function (data) {
                $scope.last = data[data.length - 1];
                $scope.first = data[0];
                $scope.banner1 = data[0];
                $scope.banner2 = data[1];
                $scope.banner3 = data[2];
                $scope.banner4 = data[3];
                $scope.banner = data;
                $scope.length = data.length;
            });
        }, function errorCallback(response) {
            errorHandle(response);
        });
    });

    // 公司简介
    app.controller('companyCtrl', function ($scope, $http) {
        $http({
            method: 'POST',
            url: "/index.php/Home/Index/company"
        }).then(function successCallback(response) {
            successHandle(response, function (data) {
                $scope.company = data;
            });
        }, function errorCallback(response) {
            errorHandle(response);
        });
    });

    // 商品
    app.controller('productCtrl', function ($scope, $http) {
        $http({
            method: 'POST',
            url: "/index.php/Home/Index/product"
        }).then(function successCallback(response) {
            successHandle(response, function (data) {
                $scope.product = data;
            });
        }, function errorCallback(response) {
            errorHandle(response);
        });
    });

</script>
<script>
    function autoScroll(obj) {
        $(obj).animate({
            marginTop: "-45px"
        }, 500, function () {
            $(this).css({marginTop: "0px"}).find("li:first").appendTo(this);
        })
    }
    $(function (){
        setInterval('autoScroll(".marque")', 3000);
        /!*调整滚动速度*!/
    })
</script>
</html>